{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "42339360",
   "metadata": {},
   "source": [
    "# 图的基本表示"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57ff7228",
   "metadata": {},
   "source": [
    "- 图的本体设计\n",
    "- 图的种类（有向、无向、异质、二分、连接带权重）\n",
    "- 节点连接数\n",
    "- 图的基本表示-邻接矩阵\n",
    "- 图的基本表示 -连接列表和邻接列表\n",
    "- 图的连通性"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09fd5936",
   "metadata": {},
   "source": [
    "图的组成\n",
    "- 节点：nodes,vertices\n",
    "- 连接：links,edges\n",
    "- 图：network,graph"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8caec9d1",
   "metadata": {},
   "source": [
    "# 图的种类"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb2fb80e",
   "metadata": {},
   "source": [
    "有向图：单向关系的图</br>\n",
    "无向图：双向关系的图</br>\n",
    "异质图：复杂关系和复杂节点的图</br>\n",
    "二分图：图中仅有两种节点，特殊的异质图</br>\n",
    "连接带权重："
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da82bfff",
   "metadata": {},
   "source": [
    "# 图的基本表示-邻接矩阵"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6691c7e",
   "metadata": {},
   "source": [
    "用N*N的绝阵来表示图中节点，N是节点数。</br>\n",
    "比如：1-4、1-2、2-4、4-3</br>\n",
    "生成矩阵如下:</br>\n",
    "[[0,1,0,1],</br>\n",
    " [1,0,0,1],</br>\n",
    " [0,0,0,1],</br>\n",
    " [1,1,1,0]]</br>\n",
    "\n",
    "如果是有向图，则指向的位置为1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4fa06752",
   "metadata": {},
   "source": [
    "# 连接列表和邻接列表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fbed95f",
   "metadata": {},
   "source": [
    "由于邻接矩阵表示图会及其稀疏，所以就有了**连接列表**和**邻接列表**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "800ba47d",
   "metadata": {},
   "source": [
    "**连接列表**：</br>\n",
    "只记录存在连接的节点对，每一个关系占用一行</br>\n",
    "**邻接列表**：</br>\n",
    "把所有与节点相关的节点记录下来，相当于每个节点占用一行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "348c7f4d",
   "metadata": {},
   "source": [
    "# 无权图和有权图"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87b2b49e",
   "metadata": {},
   "source": [
    "连接带权重，这时候邻接矩阵不再是1，是有权重的。如：</br>\n",
    "- 道路可通达性\n",
    "- 人与人之间的关系等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f68ffcd0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
